const goods = require('../db/goods');

const storeDao = {
    async allGoods() {
        let data = [
            { name: '手机', goods_list: [] },
            { name: '智能穿戴', goods_list: [] },
            { name: '笔记本 | 平板', goods_list: [] },
            { name: '家电', goods_list: [] },
            { name: '生活电器', goods_list: [] },
            { name: '厨房电器', goods_list: [] },
            { name: '智能家居', goods_list: [] },
        ];
        let result = await goods.getAllGoods();
        for (let i = 0; i < result.length; i++) {
            for (let j = 0; j < data.length; j++) {
                if (result[i].group == data[j].name) {
                    data[j].goods_list.push(result[i]);
                }
            }
        }
        return data;
    },
    async goods(id) {
        let result = await goods.getGoods(id);
        return result;
    }
};

module.exports = storeDao;
